/**
 * 
 */
package com.sys.console.business.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.sys.console.business.SysRoleService;
import com.sys.console.mapper.Sys_RoleMapper;
import com.sys.console.pojo.SysRoleLinkAuthorithDto;
import com.sys.console.pojo.Sys_Role;
import com.sys.object.common.page.PageBean;

/**
 * @author HS
 * 
 */
@Component
public class SysRoleServiceImpl implements SysRoleService {

	@Autowired	Sys_RoleMapper sysRoleMapper;
	
	@Override
	public ArrayList<Sys_Role> selectByUid(Integer uid) {
		
		return sysRoleMapper.selectByUid(uid);
	}

	@Override
	public ArrayList<Sys_Role> selectByList() throws Exception {
		// TODO Auto-generated method stub
		return sysRoleMapper.selectByList();
	}

	@Override
	public List<SysRoleLinkAuthorithDto> queryRoleAuthorityListByUid(Integer uid) throws Exception {
		// TODO Auto-generated method stub
		return sysRoleMapper.selectRoleAuthorityListByUid(uid);
	}

	@Override
	public PageBean queryPageList(Sys_Role entity, PageBean page) throws Exception {
		int rowCount = sysRoleMapper.selectByPageCount(entity);
		page.setRowCount(rowCount);
		entity.setOffset(page.getStartRow());
		entity.setLimit(page.getPerpage());
		page.setList(sysRoleMapper.selectByPage(entity));
		return page;
	}

	@Override
	public Sys_Role queryByPrimaryKey(Integer id) throws Exception {
		// TODO Auto-generated method stub
		return sysRoleMapper.selectByPrimaryKey(id);
	}

	@Override
	public int saveOrUpdate(Sys_Role entity) throws Exception {
		if(entity!=null && entity.getRid()!=null){
			return sysRoleMapper.updateByPrimaryKey(entity);
		}
		return sysRoleMapper.insert(entity);
	}

	@Override
	public int remove(Integer id) throws Exception {
		// TODO Auto-generated method stub
		return sysRoleMapper.deleteByPrimaryKey(id);
	}

	@Override
	public int delete(Integer id) throws Exception {
		// TODO Auto-generated method stub
		return sysRoleMapper.deleteByPrimaryKey(id);
	}

	@Override
	public int updateStatus(Sys_Role entity) throws Exception {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int updateStatus(String status, String[] ids) throws Exception {
		// TODO Auto-generated method stub
		return 0;
	}



}
